export const getLengthNum = (size: string): number => {
  let numSize = Number(size);
  if (size.endsWith('%') || size.endsWith('px')) {
    const match = size.match(/\d+/);
    if (match) {
      numSize = Number(match[0]);
    }
  }
  return numSize;
};

export const isValidLength = (size: string): boolean => {
  const numSize = getLengthNum(size);
  return !isNaN(numSize);
};

export const getFinalLength = (size: string, containerWidth: number): number => {
  if (size.endsWith('%')) {
    return getLengthNum(size) * containerWidth / 100;
  }
  return getLengthNum(size);
};